package com.example.ymm.modules1.service.impl.ms;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
import com.example.ymm.base.BaseServiceImpl;
import com.example.ymm.model.TableList;
import com.example.ymm.model.YmPageDto;
import com.example.ymm.modules1.entity.ms.VpmShengChanZuoYeJiHua;
import com.example.ymm.modules1.mapper.ms.VpmShengChanZuoYeJiHuaMapper;
import com.example.ymm.modules1.query.ms.VpmShengChanZuoYeJiHuaQueryCriteria;
import com.example.ymm.modules1.service.dto.ms.VpmShengChanZuoYeJiHuaDto;
import com.example.ymm.modules1.service.ms.VpmShengChanZuoYeJiHuaService;
import com.example.ymm.util.UtilValidate;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;

@Service
@Slf4j
@DS("slave2")
@DSTransactional
public class VpmShengChanZuoYeJiHuaServiceImpl extends BaseServiceImpl<VpmShengChanZuoYeJiHuaMapper, VpmShengChanZuoYeJiHua> implements VpmShengChanZuoYeJiHuaService {


    @Override
    public TableList<VpmShengChanZuoYeJiHuaDto> queryDknTableList(VpmShengChanZuoYeJiHuaQueryCriteria criteria, YmPageDto ymPage) {
        getPage(ymPage);
        if(UtilValidate.isNotEmpty(criteria.getBiaoShiHaoNoIns())){
            String[] split = criteria.getBiaoShiHaoNoIns().split(",");
            criteria.setBiaoShiHaoNoIn(Arrays.asList(split));
        }
        List<VpmShengChanZuoYeJiHuaDto> vMaterials = queryDknDataList(criteria);
        PageInfo<VpmShengChanZuoYeJiHuaDto> pageInfo = new PageInfo<>(vMaterials);
        TableList<VpmShengChanZuoYeJiHuaDto> tableList=new TableList(pageInfo);
        return tableList;
    }

    @Override
    public List<VpmShengChanZuoYeJiHuaDto> queryDknDataList(VpmShengChanZuoYeJiHuaQueryCriteria criteria) {
        return baseMapper.queryDknDataList(criteria);
    }
}
